﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;

namespace Platform.Hardware.ControlCard.Base
{
    public abstract class ControlCardBase : IControlCard
    {
        public ControlCardBase()
        {
            //MessageObservable = this.WhenAnyValue(p => p.Message);
        }
        
        public bool Initialized { get; set; }
        
        public bool Connected { get; set; }
        
        public string Message { get; set; }
        
        public IObservable<string> MessageObservable { get; set; }
        
        public IOEntity IOEntity { get; set; } = new IOEntity();
        
        public float XAxisPostion { get; set; }
        
        public float YAxisPostion { get; set; }
        
        public float ZAxisPostion { get; set; }
        
        public float LeftAxisPostion { get; set; }
        
        public float RightAxisPostion { get; set; }
        
        public float KnifeAxisPostion { get; set; }
        
        public float MainAxisPostion { get; set; }
        
        public float TrackAxisPostion { get; set; }
        
        public float StyletAxisPostion { get; set; }
        
        public int LeftAxisEnable { get; set; }
        
        public int RightAxisEnable { get; set; }

        public abstract bool AxisEnable(AxisType axis);

        public abstract bool AxisEnable(AxisType axis, bool isEnable);

        public abstract bool AxisPause(AxisType axis, int mode);

        public abstract bool AxisResume(AxisType axis);

        public abstract void Close();

        public abstract bool GetAxisPosition(AxisType axis, ref float position, ref int runState);

        public abstract bool GetMultiInput(int start, int end, ref int[] value);

        public abstract bool GetMultiOutput(ushort start, ushort end, ref uint[] value);

        public abstract bool GetSingleInput(IOType io, ref uint value);

        public abstract bool Init(ControlCardConfig controlCardConfig);

        public abstract bool MoveAbsolute(AxisType axis, float distance, CancellationToken? cancellationToken = null);

        public abstract Task<bool> MoveAbsoluteAsync(AxisType axis, float distance, CancellationToken? cancellationToken = null);
        public abstract Task<bool> MoveContinueAsync(AxisType axis, MoveDirection direction);

        public abstract bool MoveRelative(AxisType axis, float distance, CancellationToken? cancellationToken = null);

        public abstract Task<bool> MoveRelativeAsync(AxisType axis, float distance, CancellationToken? cancellationToken = null);

        public abstract bool MoveToZero(AxisType axis, CancellationToken? cancellationToken = null);

        public abstract Task<bool> MoveToZeroAsync(AxisType axis, CancellationToken? cancellationToken = null);

        public abstract bool SetSingleOutput(IOType io, uint value);

        public abstract bool SetSpeed(AxisType axis, float speed);

        public abstract bool SetUnit(AxisType axis, float unit);
        public abstract bool StopAxis(StopMode stopMode = StopMode.立即中断脉冲发送);

        public abstract bool StopAxis(AxisType axis, StopMode stopMode = StopMode.取消当前和缓冲运动);

        public abstract Task<bool> StopAxisAsync(AxisType axis, StopMode stopMode = StopMode.取消当前和缓冲运动);
    }
}
